<html>
<head><meta charset="utf-8"><title>Cargo API · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html">Cargo API</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231201289"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231201289" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Veverak <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231201289">(Mar 21 2021 at 08:05)</a>:</h4>
<p>Is there a way to use Cargo as a library, so it has an API instead of a CLI, or is there an RFC for this? I'm thinking of libgit as a role model. My use case for this feature is to create a GUI around Cargo, but this feature could also be useful for integrating Cargo with other build tools. If there isn't already an RFC, I would like to start one. IDE support is considered an area of primary focus for Rust, so I suppose there could be more people than me who are interested.</p>



<a name="231210525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231210525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231210525">(Mar 21 2021 at 11:29)</a>:</h4>
<p>Yes, cargo is published as library crate on <a href="http://crates.io">crates.io</a>: <a href="https://docs.rs/cargo/0.51.0/cargo/">https://docs.rs/cargo/0.51.0/cargo/</a></p>



<a name="231214179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231214179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Veverak <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231214179">(Mar 21 2021 at 12:41)</a>:</h4>
<p>I noticed that crate, but it took me some time to understand what it is. The readme on <a href="http://crates.io">crates.io</a> contains no information about the library, only about Cargo in general. The documentation on <a href="http://docs.rs">docs.rs</a> is empty enough to camouflage the entire purpose of the crate. The Cargo book doesn't mention it. I was able to figure out how it works only by looking for dependent crates and reading their code. It could be a lot better supported. The type <code>ops::NewOptions</code> depends on the type <code>NewProjectKind</code>, which is not exported. Every operation prints its output in text format, which is not suitable for a GUI. I guess I'll have to make a proposal to change all operations to output structured data.</p>



<a name="231659668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231659668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231659668">(Mar 24 2021 at 16:00)</a>:</h4>
<p>So far we have not stabilized any part of the API. We can and do make braking changes with each release. While eventually that will probably have to change, it will make a lot more work for the maintainers. I do not see how we can accept an RFC, without some long term source of new contributors and maintainers. Of cores I am just one vote, and I have bean wrong about the feasibility of proposed RFCs before.</p>



<a name="231660375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231660375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231660375">(Mar 24 2021 at 16:03)</a>:</h4>
<p>There are CLI commands that give stable and machine readable info about how Cargo sees a project. Mostly <code>cargo metadata</code>, but there are others. That is how we recommend programs interface with Cargo. If it is insufficient for your concrete use case, we are happy to find a way to extend it.</p>



<a name="231662617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231662617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231662617">(Mar 24 2021 at 16:16)</a>:</h4>
<p>I agree that stabilizing the cargo API just isn't something we have the bandwidth for at the moment.</p>



<a name="231662704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20API/near/231662704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20API.html#231662704">(Mar 24 2021 at 16:16)</a>:</h4>
<p>We would welcome new regular Cargo contributors, though.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>